package com.gupao;

/**
 * 咕泡2019-11-27，JMM 模拟可见性问题
 * Created by WDJ on 2019/11/27.
 */
public class VisableDemo {

    private volatile static boolean stop = false;

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new Thread(() -> {
            int i=0;
            while(!stop){
                i++;
            }
            System.out.println("i:"+i);
        });
        thread.start();
        Thread.sleep(1000);
        stop = true;
        System.out.println(stop);
    }

}
